﻿

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

//function btnOPClick(obj) {
//    $(obj).parent().parent().find("span").show();
//    $(obj).parent().hide();
//}


//function openCenter(openUrl, iWidth, iHeight) {
//    var iTop = (window.screen.availHeight - 45 - iHeight) / 2; //获得窗口的垂直位置;
//    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
//    return window.showModalDialog(openUrl, "", "dialogHeight=" + iHeight + ";dialogwidth=" + iWidth + ";dialogLeft=" + iLeft + ";dialogTop=" + iTop + ";help=no;resizable=no;status=no;scrollbars=no;");
//}

function openCenter(openUrl, iWidth, iHeight) {
    var iTop = (window.screen.availHeight - 45 - iHeight) / 2; //获得窗口的垂直位置;
    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
    window.open(openUrl, "", "width=" + iWidth + "px, height=" + iHeight + "px, top=" + iTop + ", left=" + iLeft + ",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,alwaysRaised=yes,depended=yes");
}



function openCenterScroll(openUrl, iWidth, iHeight) {

    var iTop = (window.screen.availHeight - 45 - iHeight) / 2; //获得窗口的垂直位置;
    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
    window.open(openUrl, "", "height=" + iHeight + ", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
}

function openMax(url) {
    window.open(url, "", "width=" + (screen.width - 10) + ",height=" + (screen.height - 30) + ",top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
}

function winMax() {
    self.moveTo(0, 0);
    self.resizeTo(screen.availWidth, screen.availHeight);
}

function onlyNum() {
    if (!(event.keyCode == 46) && !(event.keyCode == 8) && !(event.keyCode == 37) && !(event.keyCode == 39) && !(event.keyCode == 13))
        if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)))
            //event.returnValue=false;
            return false;
}

//水量计划输入框验证
function inputNum(obj) {
    obj.SetText(obj.GetText().replace(/[^\d]/g, ''));
}
function inputFloat(obj) {
    obj.SetText(obj.GetText().replace(/[^-?\d+\.?\d{0,2}]/g, ''));
}
//验证是否为数字类型(不含小数点)
function isAllNum(val) {
    if ((!isNaN(val) && val.indexOf(".") == -1) || val == "") {
        return true;
    }
    else {
        return false;
    }
}

//返回INT值,非数值返回0,小数则截取
function GetInt(s) {
    var val = s.GetText();
    if (!isNaN(val) && val != "") {
        if (val.indexOf(".") != -1) {
            s.SetText(val.substr(0, val.indexOf(".")));
        }
        else {
            s.SetText(val);
        }
    }
    else {
        s.SetText("0");
    }
    return parseInt(s.GetText());
}

//返回数值,非数值返回0
function GetFloat(s) {
    var val = s.GetText();
    if (val == "" || isNaN(val)) {
        s.SetText("0");
    }
    return parseFloat(s.GetText());
}
function GetNum(s) {
    if (s.GetText() == "" || isNaN(s.GetText())) {
        return 0;
    }
    else {
        return parseFloat(s.GetText());
    }
}

function GetSum(arr, sumobj) {
    var val = 0;
    for (var i = 0; i < arr.length; i++) {
        val = val + GetNum(arr[i]);
    }
    sumobj.SetText(val);
}

function GetFocus(s, e) {
    if (s.GetText() == "0") {
        s.SetText("");
    }
}
function LostFocus(s) {
    if (s.GetText() == "") {
        s.SetText("0");
    }
}


function AdjustSize(h, name) {
    var height = Math.max(0, document.documentElement.clientHeight);
    name.SetHeight(height - h);
}
/*********************************************************************************************************************/

//打开或关闭遮罩层
//on true:打开遮罩 false:关闭
//divid:要遮罩的div ID
function listCover(on, divid) {
    if (on) {
        $("#" + divid).after("<div id='divListCover'></div>");
        $("#divListCover").css({
            'opacity': 0.1,
            'position': 'absolute',
            'top': $("#" + divid).offset().top,
            'left': $("#" + divid).offset().left,
            'background-color': '#AAAAAA',
            'width': $("#" + divid).width(),
            'height': $("#" + divid).height(),
            'z-index': 5000
        });
    }
    else {
        $("#divListCover").remove();
    }
}
/*全年相同start*/
function SetFocusC(s) {
    if ($("#FocusControl").length == 0) {
        $("body").after("<input id='FocusControl' type='hidden'/>");
    }
    $("#FocusControl").val(s.globalName);
}
function GetFocusC() {
    if ($("#FocusControl").length == 0) {
        return null;
    }
    else {
        return $("#FocusControl").val();
    }
}
function SetSame(arr) {
    var preControlName = GetFocusC();
    var clientObject = ASPxClientTextBox.Cast(preControlName);
    if (clientObject == null) {
        return;
    }
    var val = clientObject.GetText();
    for (var i = 0; i < arr.length; i++) {
        if (arr[i].GetEnabled()) {
            arr[i].SetText(val);
        }
    }
}
/*全年相同end*/

/*聚焦*/
function OnKeyNext(obj) {
    if (event.keyCode == 13) {
        obj.Focus();
        if ("SelectAll" in obj) {
            obj.SelectAll();
        }
    }
}
//用于HTML原生元素
function onKeyNext(id) {
    if (event.keyCode == 13) {
        var obj = document.getElementById(id);
        obj.focus();
        if ("select" in obj) {
            obj.select();
        }
    }
}

/*双击复制值start*/
function doubleClickCopy(source, target) {
    if (target.GetEnabled()) {
        target.SetText(source.GetText());
    }
}
/*双击复制值start*/
